﻿using System;

namespace Acoris.Markdown
{
    /// <summary>
    /// 表示一个AML项的属性
    /// </summary>
    internal sealed class AMLProperty
    {
        private string m_propertyName;

        public AMLProperty(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException();
            }
            m_propertyName = name;
        }

        public string Name
        {
            get { return m_propertyName; }
        }

        public override bool Equals(object obj)
        {
            if(obj is AMLProperty property) {
                return property.m_propertyName == this.m_propertyName;
            }
            return false;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode() ^ this.m_propertyName.GetHashCode();
        }

        /// <summary>
        /// 获取与当前对象等价的字符串形式
        /// </summary>
        /// <returns>返回与当前对象等价的字符串形式</returns>
        public override string ToString()
        {
            return m_propertyName;
        }

        public static bool operator == (AMLProperty x,AMLProperty y)
        {
            return x.m_propertyName == y.m_propertyName;
        }

        public static bool operator !=(AMLProperty x,AMLProperty y)
        {
            return x.m_propertyName != y.m_propertyName;
        }
    }
}
